/* Used to make sure files are only brought in once */
#ifndef VEC3F_H
#define VEC3F_H


#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif

#include <iostream>
#include <cstdlib>

#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/gl.h>
#include <GL/glut.h>
#endif

#define _USE_MATH_DEFINES
#include <math.h>

struct Vec3f
{
	Vec3f(GLfloat v0=0.0f, GLfloat v1=0.0f, GLfloat v2=0.0f);
	Vec3f(const Vec3f& v);
	
	GLfloat V[3];
	bool ReadFromString(const char* line);
   
	GLfloat operator[] (unsigned index) const;
	GLfloat& operator[] (unsigned index);
   
	const Vec3f& operator= (const Vec3f& v);
   
	bool operator== (const Vec3f& v) const;
	bool operator!= (const Vec3f& v) const;
   
	Vec3f operator+ (const Vec3f& rhs) const;
   
	Vec3f operator- (const Vec3f& rhs) const;
   
	// Vector DOT product
	GLfloat operator* (const Vec3f& rhs) const;
   
	Vec3f operator* (GLfloat rhs) const;
   
	Vec3f operator/ (GLfloat rhs) const;
   
	// Vector CROSS Product
	Vec3f operator^ (const Vec3f& rhs) const;
   
	// Get the length
	GLfloat length() const;
   
	// Return a normalized vector
	Vec3f Normalize() const;
};

inline bool fEquals(float lhs, float rhs)
{
	// Watch for trivial equality, that is good enough, and will check for 0
	if (lhs == rhs) return true;
	float d = lhs-rhs;
	float sum2 = lhs*lhs + rhs*rhs;
	return (((d*d)/sum2) < 0.00001);
}
inline const Vec3f operator* (GLfloat lhs, const Vec3f& rhs)
{
	return rhs*lhs;
}

#endif
